import axios from 'axios' 
import { ElMessage } from 'element-plus'

const service = axios.create({
    baseURL: import.meta.env.VITE_APP_BASE_API,

})


service.interceptors.response.use(resp=>{
    const {code,message,data} = resp.data 
    if( code == 200 ){
        return Promise.resolve(data)
    }else{
        ElMessage.error(message)
        return Promise.reject(message)
    }
},error=>{
    console.log(error)
    return Promise.reject(error);
})

export default service